package com.qf.controller;


import com.qf.service.DtsUserService;
import com.qf.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/admin/stat")
@CrossOrigin("*")
public class AdminStatController {

    @Autowired
    DtsUserService userService;

    private static final int STATIS_DAYS_RANG = 30;// 统计的天数范围，一个月数据

    @RequestMapping("/user")
    public Object user(){
        Map<String,Object> data = new HashMap<>();
        String [] columns = {"day","users"};
        data.put("columns",columns);
        List<Map> rows = userService.findAll(STATIS_DAYS_RANG);
        data.put("rows",rows);
        return ResponseUtil.ok(data);

    }

}
